USE [master]
GO

/****** Object:  Database [DCM_DeepZoomService]    Script Date: 03/08/2010 10:27:02 ******/
CREATE DATABASE [DCM_DeepZoomService] ON  PRIMARY 
( NAME = N'DCM_DeepZoomService', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\DCM_DeepZoomService.mdf' , SIZE = 4092KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'DCM_DeepZoomService_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\DCM_DeepZoomService_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO

ALTER DATABASE [DCM_DeepZoomService] SET COMPATIBILITY_LEVEL = 100
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [DCM_DeepZoomService].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [DCM_DeepZoomService] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET ARITHABORT OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [DCM_DeepZoomService] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [DCM_DeepZoomService] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [DCM_DeepZoomService] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET  DISABLE_BROKER 
GO

ALTER DATABASE [DCM_DeepZoomService] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [DCM_DeepZoomService] SET READ_COMMITTED_SNAPSHOT OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [DCM_DeepZoomService] SET  READ_WRITE 
GO

ALTER DATABASE [DCM_DeepZoomService] SET RECOVERY SIMPLE 
GO

ALTER DATABASE [DCM_DeepZoomService] SET  MULTI_USER 
GO

ALTER DATABASE [DCM_DeepZoomService] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [DCM_DeepZoomService] SET DB_CHAINING OFF 
GO


USE [DCM_DeepZoomService]
GO
/****** Object:  Table [dbo].[Images]    Script Date: 03/08/2010 10:27:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Images](
	[SourceImageKey] [varchar](512) NOT NULL,
	[SourceImageUri] [nvarchar](512) NOT NULL,
	[PublicDzImageUri] [nvarchar](512) NOT NULL,
	[PrivateDzImageUri] [nvarchar](512) NOT NULL,
	[LastUpdated] [datetime] NOT NULL,
 CONSTRAINT [PK_Images] PRIMARY KEY CLUSTERED 
(
	[SourceImageKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  StoredProcedure [dbo].[SaveImage]    Script Date: 03/08/2010 10:27:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[SaveImage]
	@SourceImageKey nvarchar(100) = null,
	@SourceImageUri nvarchar(512) = null,
	@PublicDzImageUri nvarchar(512) = null,
	@PrivateDzImageUri nvarchar(512) = null,
	@LastUpdated DateTime = null
AS
BEGIN

	IF Exists(Select * from [dbo].[Images] Where @SourceImageKey = [SourceImageKey])
		Update [dbo].[Images]
		Set [SourceImageUri] = @SourceImageUri,
			[PublicDzImageUri] = @PublicDzImageUri,
			[PrivateDzImageUri] = @PrivateDzImageUri,
			[LastUpdated] = @LastUpdated
		Where @SourceImageKey = [SourceImageKey]
	ELSE
		Insert [dbo].[Images] ([SourceImageKey],[SourceImageUri],[PublicDzImageUri],[PrivateDzImageUri],[LastUpdated])
		Values(@SourceImageKey, @SourceImageUri, @PublicDzImageUri, @PrivateDzImageUri, @LastUpdated)
		
END
GO
/****** Object:  StoredProcedure [dbo].[GetImage]    Script Date: 03/08/2010 10:27:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetImage]
	@SourceImageKey nvarchar(1024) = null
AS
BEGIN
	SET NOCOUNT ON;

	SELECT [SourceImageKey],
		[SourceImageUri],
		[PublicDzImageUri],
		[PrivateDzImageUri],
		[LastUpdated]
	FROM [dbo].[Images]
	Where [SourceImageKey] = @SourceImageKey
END
GO


